<?php

/*

  Treasure	$5

  Worth $0.
  When you play this, gain a card costing up to $1 per differently named card you have in play, counting this. If it’s a Victory card, trash this.

 */

class HornOfPlenty extends Card implements iTreasure, iKingdom, iCornucopia {

    public function __construct() {
        parent::__construct("Horn of Plenty", 5);
        $this->undoPlay = false;
        $this->undoBuy = true;
    }

    public function getDescription() {
        return array(
            "Worth $0",
            "When you play this, gain a card costing up to $1 per differently named card you have in play, counting this. If it’s a Victory card, trash this.");
    }
    
    public function autoPlayNum(Game $game) {
        return -1;
    }
    
    public function play(Game $game, $isRealCard) {
        $playArea = $game->getPlayArea();
        $unique = getUniqueCards($playArea);
        $optional_cards = $game->getBoardCardsByPrice(0, sizeof($unique));


        $output = MySocket::GetUserReply($game, Input_ChooseOne, $optional_cards, 1, 1, null, "Choose card to gain");
        $card_name = $output[0];
        $card = $game->moveCardFromPileToPile($card_name, BoardCards, DiscardPile);
         ScreenDisplay::addScreenMessage($game, true, "gain " . nicePrint($card), "gains " . ScreenDisplay::$LMSG);

        if ($card instanceof iVictory) {
            $game->moveCardFromPileToPile($this, PlayArea, Trash);
             ScreenDisplay::addScreenMessage($game, false, " and trash ".  nicePrint($this), " and trashes ".ScreenDisplay::$LMSG);
        }
        $game->cardPaymentFinished();
        return true;
    }

}

?>